package API.JDK8时间.工具类;

import java.time.LocalDateTime;
import java.time.Duration;
public class duration {
    public static void main(String[] args) {
        /*
        * Durattion 用于计算两个"时间"间隔（秒，纳秒）
        *period  用于计算两个”日期“间隔（年月日）
        *chronoUnit 用于计算两个”日期 “间隔
        * */

        LocalDateTime now = LocalDateTime.now();//获取当前时间对象
        System.out.println(now);

        //设置一个时间
        LocalDateTime localDateTime = LocalDateTime.of(2000,1,1,0,0,0);
        System.out.println(localDateTime);

        Duration between = Duration.between(localDateTime, now);//第二个参数减第一个参数
        System.out.println("相差时间间隔对象："+ between);//PT217072H59M47.4246151S
//      PT217072H59M47.4246151S: 217072Hour  59Month  4246151Second


    }
}
